package com.example.demo.demos.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Controller
@ResponseBody
public class newController {
    @Autowired
    private Environment env;
    @GetMapping("/sa1")
    public String getEnvironment1(){
        String name=env.getProperty("app.name");
        String version=env.getProperty("app.version");
        String descripition=env.getProperty("app.descripition");
        return "name:"+name+"version:"+version+"descripition"+descripition;
    }
    @Value("${app.name}")
    private String name;
    @Value("${app.version}")
    private String version;
    @Value("${app.descripition}")
    private String descripition;
    @GetMapping("/sa2")
    public String getEnvironment2(){
        return "name:"+name+"version:"+version+"descripition"+descripition;
    }
    @Autowired
    AppProperties appProperties;
    @GetMapping("/sa3")
    public String getEnvironment3(){
        return appProperties.toString();
    }
}
